package com.homework4;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class server {
    public static void main(String[] args) {
        try {
            ServerSocket serverSocket = new ServerSocket(8888);

            Socket accept = serverSocket.accept();
            System.out.println("客户端ip地址:"+accept.getInetAddress().getHostAddress());
            InputStream inputStream = accept.getInputStream();
            int len;
            byte[] bytes=new byte[1024];
            while ((len=inputStream.read(bytes))!=-1){
                System.out.println(new String(bytes,0,len));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
